import Mock from "mockjs";

// 定义数据类型
let data = Mock.mock([{
        username: "root",
        password: "123456",
        name: "zhangsan",
        token: "000111222333444555666",
        id: "01|+1",
    },
    {
        username: "@word(3, 5)",
        password: "123456",
        name: "@name",
        token: "@guid()",
        "id|+1": 3,
    },
]);

class StudentsService {
    getDate() {
        return Promise.resolve({
            data,
        });
    }
    login(user, pass) {
        let flag = false;

        // console.log(user);
        for (let i in data) {
            if (data[i].username == user && data[i].password == pass) {
                flag = true;
                break;
            } else {
                flag = false;
                break;
            }
        }
        if (flag) {
            return Promise.resolve("成功");
        } else {
            return Promise.resolve("失败");
        }
    }
}

const service = new StudentsService();
export default service;